use BogoCommands;
package BogoHeader;

sub new{
	my $class = shift;
	my $self = bless{
		SESSIONID=>0,
		CLIENTID=>0,
		CMD => 0,
		CONTENTSZ=>0
	}, $class;
		
}
sub sethdata{
	my $self = shift;
	my ($clientId, $SessionId, $cmd, $ContentSz) = @_;
	$self->{CLIENTID} = $clientId;
	$self->{SESSIONID} = $SessionId;
	$self->{CMD}       = BogoCommands->getEnumbyName($cmd,'client');
	$self->{CONTENTSZ} = $ContentSz;
}
sub showdata{
	my $self = shift;
	print "Header:\n  Client Id:".$self->{CLIENTID}.
		  "\n  SessionId: ".$self->{SESSIONID}.
		  "\n  CMd: ".$self->{CMD}.
		  "\n  Content size: " .$self->{CONTENTSZ}.
		  "\n=========\n";
}
package BogoContent;

sub new{
	my $class = shift;
	my $self = bless{
		DATASET => {},
		MCONTENT=>undef,
		FORMAT=>undef
	}, $class;
	return $self;
}

sub setdata{
	my $self = shift;
	$self->{DATASET} = shift;
}
sub getsz{
	my $self = shift;
	
}
sub marshallContent{
	
}

package BogoMsg;



sub new{
	my $class = shift;
	my $self = bless{
		HEADER => BogoHeader->new(),
		CONTENT => undef
	}, $class;
	return $self;
}

sub setdata{
	my $self = shift;
	my ($clientId, $SessionId, $ContentSz) = @_;
	$self->{HEADER}->sethdata($clientId, $SessionId, $ContentSz);
	
}
sub setHeader{
	my $self = shift;
	$self->{HEADER} = shift;
}
sub marshall{
	my $self = shift;
	my $hformat = "i l i i ";
	my $cformat = $self->{CONTENT}->{FORMAT};
	my $packeddata = pack($hformat, $self->{HEADER}-{CLIENTID},$self->{HEADER}-{SESSIONID},
							  $self->{HEADER}-{CMD},$self->{HEADER}-{CONTENTSZ},
							   );
	$packeddata .= $self->{CONTENT}->marshallContent();
	return $packeddata;
}
sub printHeader{
	my $self = shift;
	$self->{HEADER}->showdata();
}

sub setContent{
	my $self = shift;
	$self->{CONTENT} = shift;
	$self->{HEADER}->{CONTENTSZ} = $self->{CONTENT}->getsz();
	 
}
1;